<template>
	<view>
		<uni-nav-bar title="详细资料" :statusBar="true" :border="false" left-icon="back" :fixed="true"
			@clickLeft="$tab.back()">
		</uni-nav-bar>
		<view class="p-20 bg-FFF mt-16" v-if="detail">
			<view class="flex items-center">
				<image :src="detail.friendInfo.avatar" class="image-96 round" mode=""></image>
				<view class="ml-24">
					<view class="text-32">
						{{ detail.friendInfo.nickName }}
					</view>
					<view class="text-9E9E9E mt-8">
						用户名：{{detail.friendInfo.userName}}
					</view>
				</view>
			</view>

			<view class="bg-F8F8F8 p-24 mt-28" v-if="detail.content">
				{{detail.content}}
			</view>

			<view class="py-40 flex justify-between items-center" v-if="userInfo.userId == detail.targetUserId">
				<view class="font-500">
					备注昵称
				</view>
				<view class="">
					<u--input placeholder="备注" placeholder-style="text-align:right" v-model="createGroupName"
						border="bottom"></u--input>
				</view>
			</view>
		</view>

		<view class="px-20 py-32 bg-FFF mt-16 flex justify-between items-center" v-if="detail">
			<view class="">
				用户名
			</view>
			<view class="">
				{{detail.friendInfo.userName}}
			</view>
		</view>
		
		<view class="" v-if="detail">
			<view class="px-20 py-32 bg-FFF mt-16 text-center text-9E9E9E"
				v-if="userInfo.userId != detail.targetUserId && detail.state == 0">
				等待对方验证
			</view>
			
			<view class="add round-16 text-center text-FFF text-32"
				v-if="userInfo.userId == detail.targetUserId && detail.state == 0" @click="confirm">
				同意
			</view>
		</view>

		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: "",
				detail: null,
				createGroupName: "",
				userInfo: this.$store.getters.userInfo,
			};
		},
		onLoad(e) {
			this.id = e.id
			this.getData()
		},
		methods: {
			async getData() {
				const res = await this.$Api.chat.newFriendListDetail(this.id)
				console.log('新的朋友详情', res)
				this.detail = res.data
			},
			async confirm() {
				const res = await this.$Api.chat.addressBookVerify({
					id: this.id,
					state: 1,
					createGroupName: this.createGroupName
				})
				
				this.$modal.msg('添加成功!')
				this.$tab.back(1500)

				console.log('同意添加', res)
			}
		}
	}
</script>

<style lang="scss">
	/deep/ .uni-input-input {
		text-align: right;
	}

	.add {
		width: 480rpx;
		height: 80rpx;
		background: #FF323B;
		line-height: 80rpx;
		margin: 48rpx auto 0;
	}
</style>